#define _CRT_SECURE_NO_WARNINGS  1


class Solution {
public:
    string addStrings(string num1, string num2)
    {
        int end1 = num1.size() - 1;
        int end2 = num2.size() - 1;
        string Ret;
        int carry = 0;

        while (end1 >= 0 || end2 >= 0)
        {
            int ret1 = end1 >= 0 ? num1[end1] - '0' : 0;
            int ret2 = end2 >= 0 ? num2[end2] - '0' : 0;

            int ret3 = ret1 + ret2 + carry;
            carry = ret3 / 10;
            ret3 %= 10;
            Ret += (ret3 + '0');

            end1--;
            end2--;
        }
        if (carry != 0)
        {
            Ret += '1';
        }

        reverse(Ret.begin(), Ret.end());
        return Ret;
    }
};